<template>
    <div class="activity-contain">
        <div class="main">
            <el-form :model="params" :rules="rules1" ref="information" label-width="120px" class="">
                <el-form-item label="手机号：" prop="phone_num">
                    <el-input v-model.number="params.phone_num" placeholder="请输入手机号"></el-input>
                </el-form-item>
                <el-form-item label="密码：" prop="password">
                    <el-input v-model="params.password" placeholder="请输入密码"></el-input>
                </el-form-item>
                <el-form-item label="邀请码：" prop="invitation_code">
                    <el-input v-model="params.invitation_code" placeholder="请输入邀请码"></el-input>
                </el-form-item>
                <el-form-item label="增加余额：" prop="balance_val">
                    <el-input v-model="params.balance_val" placeholder="请输入增加余额"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="submitForm('information')" >保存</el-button>
                    <el-button @click="$router.back()" type="primary" >返回</el-button>
                </el-form-item>
            </el-form>
        </div>
    </div>
</template>

<script>
	let CONSTANT = require('../constant/constant.js');
	let common = require("../common.js");
	export default {
		data() {
			var validateMobile = (rule, value, callback) => {
				if (value === '') {
					callback(new Error('请输入手机号码'));
				}
				else if (!(/^1[34578]\d{9}$/.test(value))) {
					callback(new Error('手机号码不合法!'));
				}
				else {
					callback();
				}
			};
			return {
				id:'',
				upLoadUrl:'',
				dialogImageUrl:'',
				information: {
					id:'',
					picIds:[],
					isHot:'',
					rvName:'',
					contents:'',
					resume:'',
					provinceCode:'',
					provinceName:'',
					cityName:'',
					cityCode:'',
					priceDay:'',
					priceMonth:'',
					setNum:'',
					maxDriverRouter:'',
					outputVolume:'',
					gearBox:'',
					driverLicense:'',
					picMasterId:'',
					loadNum:'',
					bedNum:'',
					rvLevel:'',
					rvSize:'',
					maxSpeed:'',
					rvDesc:'',
					construction:'',
				},
				uploadShow1:false,
				uploadShow:false,
				dialogVisible:false,
				fileCoverList:[],
				filePcList:[],
				takeoutId:'',
				rules1: {
					phone_num: [
						{ required: true, message: '请输入手机号', trigger: 'blur' },
						{ validator: validateMobile, trigger: 'blur' }
					],
					password: [
						{ required: true, message: '请输入密码', trigger: 'blur' }
					],
				},
				rules: {
					rvName: [
						{ required: true, message: '请输入房车车型', trigger: 'blur' },
						{ min: 1, max: 35, message: '长度在 1 到 35 个字', trigger: 'blur' }
					],
					resume: [
						{ required: true, message: '请输入简述', trigger: 'blur' },
						{ min: 1, max: 50, message: '长度在 1 到 50 个字', trigger: 'blur' }
					],
					picMasterId:[
						{required: true, message: '请上传图片', trigger: 'change'  }
					],
					picIds:[
						{required: true, message: '请上传图片', trigger: 'change'  }
					],
					isHot:[
						{required: true, message: '请选择是否热门', trigger: 'change'  }
					],
					cityCode:[
						{required: true, message: '请选择省市', trigger: 'change'  }
					],
					priceDay:[
						{required: true, message: '请填写日租价格', trigger: 'change'  }
					],
					priceMonth: [
						{ required: true, message: '请填写月租价格', trigger: 'change' },
					],
					status :[
						{ required: true, message: '请填选择状态', trigger: 'change' },
					]
				},
				provinceList:[],
				cityList:[],
				imageUrl:'',
				url: "",
				params: {
					phone_num: "",
					password: "",
					invitation_code: "",
					balance_val: ""
				}
			};
		},
		components:{
			'bg-editor':()=>import('./common/bg-editor.vue')
		},
		created(){
		},
		mounted() {
		},
		methods: {
			submitForm(formName) {
				this.$refs[formName].validate((valid) => {
					if (valid) {
						let url = CONSTANT.URL.userCreate;
						common.requestAjax(url, this.params, null, res => {
							if(res.status == 0) {
								this.$message({
									type: 'success',
									message: '保存成功!'
								});
								this.$router.back();
							} else {
								this.$message({
									type: 'error',
									message: res.msg
								});
							}
						});
					} else {
						console.log('error submit!!');
						return false;
					}
				});
			},
		}
	}
</script>

<style lang="scss" scoped >
    .activity-contain {
        .header{
            height: 46px;
            padding-bottom: 10px;
            border-bottom: 1px solid #dedede;
            p{ float: left;height: 36px;line-height: 36px;margin: 0 0 0 10px;font-size: 18px;}
            .el-button{
                float: right;
                margin-right: 5%
            }
        }
        .tip-img{
            font-size: 12px;
            color:red;
        }
        .main {
            // width:500px;
            //max-width: 1500px;
            .el-textarea{
                width: 60%;
            }
            .car-info{
                .car-list{
                    overflow: hidden;
                    .el-form-item{
                        float: left;
                        .el-input,.el-select{
                            width: 150px;
                        }
                    }
                }
            }
            margin: 20px 0 0 40px;
            clear: both;
            .el-input,
            .el-select {
                width: 250px;
            }
            .modal-body{
                .note-image-input{
                    display: block;
                }
            }
        }
    }
</style>
<style>
    .distpicker-address-wrapper select{
        margin-right: 20px;
    }
    .panel-heading{
        position: relative!important;
    }
    .note-toolbar{
        z-index: 10!important;
    }
    .uploadShow  .el-upload{display: none;}
</style>

